<?php
/**
 * Created by xuan.
 * Author: xuan
 * Date: 2018/8/3
 * Time: 18:24
 */

namespace app\api\model;
use think\Db;

class Goodscat extends BaseModel
{	
	protected $table = 'goodscat';
	
	public static function selectOneGoodscatByID($id){
		$data = model("Goodscat")->where(array("id"=>$id))->find();
		return $data;
	}
	
	public static function GoodscatLists(){
		$data = model("Goodscat")->select();
		return $data;
	}
	
	public static function GoodscatListsHome(){
		$data = model("Goodscat")->where('isshow=1')->select();
		return $data;
	}
	
	public static function addOneGoodscat($all)
    {
		$data = Goodscat::create([
			'catname' => $all['catname'],
			'type' => $all['type'],
			'isshow' => $all['isshow'],
			'orderby' => $all['orderby'],
			'addtime' => date('Y-m-d H:i:s',time()),
			'updatetime' => date('Y-m-d H:i:s',time())
		]);
		  
		return $data;
    }
	
	public static function updOneGoodscat($all)
    {
		$data=Db::name('Goodscat')-> where('id',$all['id'])->update([
			'catname' => $all['catname'],
			'type' => $all['type'],
			'isshow' => $all['isshow'],
			'orderby' => $all['orderby'],
			'addtime' => date('Y-m-d H:i:s',time()),
			'updatetime' => date('Y-m-d H:i:s',time())
		]);
		return $data;
    }
	
	public static function delOneGoodscat($id)
    {
		$data=Db::name('Goodscat')-> where('id',$id)->delete();
		return $data;
    }
}